'use strict';
module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('links', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      content_id: {
        type: Sequelize.INTEGER,
        allowNull: false
      },
      user_id: {
        type: Sequelize.INTEGER,
        allowNull: false
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    }, {
      charset: 'utf8mb4',
      collate: "utf8mb4_bin"
    });
    await queryInterface.addIndex('links', {
      name: "content_id",
      fields: ['content_id']
    })
    await queryInterface.addIndex('links',{
        name:"user_id",
        fields:["user_id"]
    })
  },
  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('links', []);
  }
};